package com.baosight.sczx.common.zm.basetools.listener;

import java.util.HashMap;
import java.util.Map;

import com.baosight.innerinterface.service.TablePk;
import com.baosight.iplat4j.core.spring.SpringApplicationContext;
import com.baosight.iplat4j.dao.Dao;
import com.baosight.sczx.common.zm.basetools.StaticTools;
import com.baosight.sczx.zm.cn.domain.ZMCNQtyMain;


public class GetOtherCoalSampleTestResult {
	private static Dao dao = (Dao)SpringApplicationContext.getBean("dao");

	/**
	 * 从检测表提取数据到抽查表
	 * @return
	 */
	public String getOtherCoalSampleTestResult(){
		dao.insert("ZMCNCcy.insert_autorun",null);
		return "ok";
	}
	/**
	 * 生成其他样主表
	 * @return
	 */
	public String generateMain(){
		Map<String,String> _map=new HashMap<String,String>();
		String fdYear=StaticTools.getYear();
		String fdMonth=StaticTools.getMonth();
		_map.put("fdYear",fdYear);
		_map.put("fdMonth",fdMonth);
		int count=dao.count("ZMCNQtyMain.count", _map);
		if(count>0){
			//当月记录已经生成，直接退出
			return "ok";
		}
        ZMCNQtyMain qty=new ZMCNQtyMain();
        qty.setFdKeyId(TablePk.getInstance().getNextValue("T_CN_QTY_MAIN"));
        qty.setFdYear(fdYear);
        qty.setFdMonth(fdMonth);
        dao.insert("ZMCNQtyMain.insert",qty);
		return "ok";
	}
}
